package com.muyan.singleton.v4;

/**
 * @Author: YLTDMenglc
 * @Date: 2019/6/11
 * @Time: 13:42
 * @Description: 饿汉变种模式
 * 基于静态 代码块，在实例化或者第一次调用时执行
 * 既可以延迟加载，又线程安全
 */
public class Sinleton4 {

    private static Sinleton4 sinleton;

    public Sinleton4() {
        System.out.println("constructor");
    }

    static {
        System.out.println("static");
        sinleton = new Sinleton4();
    }

    public static Sinleton4 getSinleton() {
        return sinleton;
    }
}
